package com.ruoyi.location.service;

import com.ruoyi.location.pojo.Location;
import com.ruoyi.location.utils.MyUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class getLocation {

    /*
       按照日期选择两个日期中的所有位置信息
     */
    public static List<Location> choose(List<Location> location, String  s1, String s2){
        List<Location> loc = MyUtils.sortByDate(location);
        Date d1 = MyUtils.stringToDate(s1);
        System.out.println(d1);
        Date d2 = MyUtils.stringToDate(s2);
        ArrayList<Location> locations = new ArrayList<>();
        for (Location i : loc)
        {
            Date temp = MyUtils.stringToDate(i.getLocationTime());
            if(temp.after(d1) && temp.before(d2)){
                locations.add(i);
            }
        }
        return locations;
    }
}
